import { http } from '@/utils/http'
import { Profile, ProfileParams } from '@/types/member'

// 手机号登录（企业用户ID才能调用）
export const phoneLogin = (data: {
  encryptedData: string
  iv: string
  code: string
}) => {
  return http<Profile>({
    url: '/login/wxMin',
    method: 'POST',
    data
  })
}

// 模拟登录
export const simpleLogin = (phoneNumber: string) => {
  return http<Profile>({
    url: '/login/wxMin/simple',
    method: 'POST',
    data: { phoneNumber }
  })
}

// 获取用户信息
export const getMemberProfile = () => {
  return http<Profile>({
    url: '/member/profile'
  })
}

// 更新用户信息
export const updateMemberProfile = (data: ProfileParams) => {
  return http<Profile>({
    url: '/member/profile',
    method: 'PUT',
    data
  })
}
